
import 'package:json_annotation/json_annotation.dart';

// 每个文件有一个就好
part 'DemoModel.g.dart';

@JsonSerializable(nullable: false)
class DemoModel extends Object {
  DemoModel(this.root);

  List<CategoryModel> root; 

  //不同的类使用不同的mixin即可
  factory DemoModel.fromJson(Map<String, dynamic> json) => _$DemoModelFromJson(json);
  Map<String, dynamic> toJson() => _$DemoModelToJson(this);
}

@JsonSerializable(nullable: false)
class CategoryModel extends Object {
  CategoryModel(this.name, this.children);

  String name;
  List<PageModel> children; 

  //不同的类使用不同的mixin即可
  factory CategoryModel.fromJson(Map<String, dynamic> json) => _$CategoryModelFromJson(json);
  Map<String, dynamic> toJson() => _$CategoryModelToJson(this);
}


@JsonSerializable(nullable: false)
class PageModel {
  String name;

  @JsonKey(name: 'class')
  String className;
  PageModel(this.name, this.className);

  //不同的类使用不同的mixin即可
  factory PageModel.fromJson(Map<String, dynamic> json) => _$PageModelFromJson(json);
  Map<String, dynamic> toJson() => _$PageModelToJson(this);
}

